Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit f8c57e675e6f7aa9a811c65d21fbe873f42736b0


Parents : 66f72ea
Author : Mark Qvist <bc7291552be7a58f361522990465165c>
Date : 2026-05-21T22:55:26+02:00

Fixed anchors not updating scroll position

Changes

3 files changed, 21 insertions(+), 14 deletions(-)


Diff

diff --git a/nomadnet/ui/textui/Browser.py b/nomadnet/ui/textui/Browser.py
index 7cc4a65..a08d8e6 100644
--- a/nomadnet/ui/textui/Browser.py
+++ b/nomadnet/ui/textui/Browser.py
@@ -342,6 +342,7 @@ class Browser:
try:
scrollable = self.browser_body.original_widget.original_widget
+ scrollable.anchor_cursor_update = True
scrollable.set_scrollpos(self._rows_above(int(target_idx), cols))
except Exception as e:
RNS.log("Anchor jump failed: "+str(e), RNS.LOG_ERROR)

diff --git a/nomadnet/ui/textui/Guide.py b/nomadnet/ui/textui/Guide.py
index b82245b..a738288 100644
--- a/nomadnet/ui/textui/Guide.py
+++ b/nomadnet/ui/textui/Guide.py
@@ -227,6 +227,7 @@ class GuideDisplay():
pile = urwid.Pile(new_content)
self._content_attrmaps = new_content
self._content_scrollable = Scrollable(pile)
+ pile.automove_cursor_on_scroll = True
content = urwid.LineBox(urwid.AttrMap(ScrollBar(self._content_scrollable, thumb_char="\u2503", trough_char=" "), "scrollbar"))
self.columns.contents[1] = (content, options)
@@ -255,6 +256,8 @@ class GuideDisplay():
return
row_offset = _rows_above(attrmaps, target_idx, cols)
try:
+ scrollable.force_cursor_update = True
+ scrollable.anchor_cursor_update = True
scrollable.set_scrollpos(int(row_offset))
except Exception:
pass
@@ -1346,19 +1349,19 @@ With micron you can easily create structured documents and pages with formatting
>Table of Contents
- `F44f`_`[A Few Demo Outputs`#a-few-demo-outputs]`_`f
- `F44f`_`[Micron Tags`#micron-tags]`_`f
- `F44f`_`[High Level Stuff`#high-level-stuff]`_`f
- `F44f`_`[Colors`#colors]`_`f
- `F44f`_`[Page Foreground and Background Colors`#page-foreground-and-background-colors]`_`f
- `F44f`_`[Links`#links]`_`f
- `F44f`_`[Anchors`#anchors]`_`f
- `F44f`_`[Tables`#tables]`_`f
- `F44f`_`[Fields & Requests`#fields-requests]`_`f
- `F44f`_`[Comments`#comments]`_`f
- `F44f`_`[Partials`#partials]`_`f
- `F44f`_`[Literals`#literals]`_`f
- `F44f`_`[Closing Remarks`#closing-remarks]`_`f
+ `F79d`_`[A Few Demo Outputs`#a-few-demo-outputs]`_`f
+ `F79d`_`[Micron Tags`#micron-tags]`_`f
+ `F79d`_`[High Level Stuff`#high-level-stuff]`_`f
+ `F79d`_`[Colors`#colors]`_`f
+ `F79d`_`[Page Foreground and Background Colors`#page-foreground-and-background-colors]`_`f
+ `F79d`_`[Links`#links]`_`f
+ `F79d`_`[Anchors`#anchors]`_`f
+ `F79d`_`[Tables`#tables]`_`f
+ `F79d`_`[Fields & Requests`#fields-requests]`_`f
+ `F79d`_`[Comments`#comments]`_`f
+ `F79d`_`[Partials`#partials]`_`f
+ `F79d`_`[Literals`#literals]`_`f
+ `F79d`_`[Closing Remarks`#closing-remarks]`_`f
>>Recommendations and Requirements

diff --git a/nomadnet/vendor/Scrollable.py b/nomadnet/vendor/Scrollable.py
index 7accf8f..dc130d4 100644
--- a/nomadnet/vendor/Scrollable.py
+++ b/nomadnet/vendor/Scrollable.py
@@ -53,6 +53,7 @@ class Scrollable(urwid.WidgetDecoration):
self._rows_max_cached = 0
self.force_forward_keypress = force_forward_keypress
self.force_cursor_update = False
+ self.anchor_cursor_update = False
self.cursor_update_forced_at = 0
super().__init__(widget)
@@ -108,9 +109,11 @@ class Scrollable(urwid.WidgetDecoration):
# Trimmed canvas contains the cursor, e.g. in an Edit widget
self._forward_keypress = True
else:
- force_check = self.force_cursor_update and (time.time()-self.cursor_update_forced_at < 0.25)
+ force_check = self.force_cursor_update and (time.time()-self.cursor_update_forced_at < 0.25)
+ force_check |= self.anchor_cursor_update
if canv_full.cursor is not None or force_check:
self.force_cursor_update = False
+ self.anchor_cursor_update = False
# Full canvas contains the cursor, but scrolled out of view
self._forward_keypress = False


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────